<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
    <meta charset="UTF-8">  
    <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link href="${ctx}/resources/semanticui/semantic.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
    <title>HR公司信息</title>  
</head>
<body>
<div class="ui segment" id="n-page">
        <div class="ui segment" id="n-content">
            <form class="ui form">
                <div class="field">
                    <label><span style="color: red">*</span>公司名称</label>
                    <div class="ui input">
                    <!--
                    <input type="hidden" name="companyid" id="companyid" value="${tempcompany.id}" >
                    -->
                    <input type="text" name="companyname" id="companyname" value="${tempcompany.name}" disabled>
                    </div>
                </div>
                <div class="field">
                    <label><span style="color: red">*</span>Company Name</label>
                    <div class="ui input">
                        <input type="text" name="englishname" id="englishname" value="${tempcompany.englishName}" placeholder="请输入公司英文名称">
                    </div>
                </div>
                <div class="field">
                    <label><span style="color: red">*</span>公司性质</label>
                    <select class="ui search dropdown" name="property" id="property">
                        <option value="0" >请选择公司性质</option>
                        <option value="1" <c:if test="${1 eq tempcompany.property}">selected</c:if>>外商独资/外企办事处</option>
                        <option value="2" <c:if test="${2 eq tempcompany.property}">selected</c:if>>中外合资（合资/合作）</option>
                        <option value="3" <c:if test="${3 eq tempcompany.property}">selected</c:if>>私营/民营企业</option>
                        <option value="4" <c:if test="${4 eq tempcompany.property}">selected</c:if>>国有企业</option>
                        <option value="5" <c:if test="${5 eq tempcompany.property}">selected</c:if>>国内上市公司</option>
                        <option value="6" <c:if test="${6 eq tempcompany.property}">selected</c:if>>政府机关/非盈利机构</option>
                        <option value="7" <c:if test="${7 eq tempcompany.property}">selected</c:if>>事业单位</option>
                        <option value="8" <c:if test="${8 eq tempcompany.property}">selected</c:if>>其他</option>
                    </select>
                </div>
                <div class="field">
                    <label><span style="color: red">*</span>公司规模</label>
                    <select class="ui search dropdown" name="scope" id="scope">
                        <option value="0">请选择公司规模</option>
                        <option value="1" <c:if test="${1 eq tempcompany.scope}">selected</c:if>>50人以下</option>
                        <option value="2" <c:if test="${2 eq tempcompany.scope}">selected</c:if>>50-199人</option>
                        <option value="3" <c:if test="${3 eq tempcompany.scope}">selected</c:if>>200-499人</option>
                        <option value="4" <c:if test="${4 eq tempcompany.scope}">selected</c:if>>500-999人</option>
                        <option value="5" <c:if test="${5 eq tempcompany.scope}">selected</c:if>>1000-1999人</option>
                        <option value="6" <c:if test="${6 eq tempcompany.scope}">selected</c:if>>2000-4999人</option>
                        <option value="7" <c:if test="${7 eq tempcompany.scope}">selected</c:if>>5000人以上</option>
                    </select>
                </div>
                <div class="field">
                    <label><span style="color: red">*</span>细分领域</label>
                    <select class="ui search dropdown" name="domainid" id="domainid">
                        <option value="">请输入细分领域</option>
                        <c:forEach items="${domains}" var="dm">

                            <option value="${dm.id}" <c:if test="${dm.id  eq tempcompany.domain}">selected</c:if>>${dm.name}</option>

                        </c:forEach>
                    </select>
                </div>
                <div class="field">
                    <label>标签分类</label>
                    <div class="ui input">
                        <select class="ui search dropdown" name="tags" id="tags">
                            <option value="0">请选择标签分类</option>
                            <option value="1" <c:if test="${1 eq tempcompany.tags}">selected</c:if>>TOP500</option>
                            <option value="2" <c:if test="${2 eq tempcompany.tags}">selected</c:if>>行业新贵</option>
                            <option value="2" <c:if test="${3 eq tempcompany.tags}">selected</c:if>>其他</option>
                        </select>
                    </div>
                </div>
                <div class="field">
                    <label><span style="color: red">*</span>公司地址</label>
                    <div class="ui input">
                        <input type="text" name="companyaddress" id="companyaddress" value="${tempcompany.address}" placeholder="请输入公司地址">
                    </div>
                </div>

                <div class="field">
                    <label><span style="color: red">*</span>联系人姓名</label>
                    <div class="ui input">
                        <input type="text" name="companycontact" id="companycontact" value="${linkman.linkmanName}" placeholder="请输入联系人姓名">
                    </div>
                </div>
              <div class="field">
                    <label>联系人职位</label>
                    <div class="ui input">
                        <input type="text" name="position" id="position" value="${linkman.linkmanPosition}" placeholder="请输入联系人职位">
                    </div>
                </div>
                <div class="field">
                    <label>联系人电话</label>
                    <div class="ui input">
                        <input type="text" name="companyphone" id="companyphone" value="${linkman.linkmanPhone}" placeholder="请输入联系人电话">
                    </div>
                </div>
                <!--  <div class="field">
                    <label>公司邮箱</label>
                    <div class="ui input">
                        <input type="text" name="companyemail" id="companyemail" placeholder="请输入公司邮箱" value="${tempcompany.email}">
                    </div>
                </div>
                 <div class="field">
                    <label>组织机构代码</label>
                    <div class="ui input">
                        <input type="text" name="orgcode" id="orgcode" value="${tempcompany.orgnizationCode}" placeholder="请输入组织机构代码">
                    </div>
                </div>
                <div class="field">
                    <label>营业执照编码</label>
                    <div class="ui input">
                        <input type="text" name="bizcode" id="bizcode" value="${tempcompany.licenseCode}" placeholder="请输入营业执照编码" >
                    </div>
                </div>   -->                    
                <input type="hidden" name="employerId" id="employerId" value="${employer.id}"/>
            </form>        
        </div>
        
        <div class="ui segment" id="btn-next2">
            <div class="fluid ui button" id="next">保存</div>
        </div>
      
       <!--  <div class="ui center aligned segment" id="choice-buttons"> 
            <div class="two ui buttons"> 
                <div class="ui button active dog" id="next">下一步</div> 
                <div class="ui button active dog" id="closeit">回首页</div> 
            </div>
        </div> -->

</div>

<script src="${ctx}/resources/jweixin-1.0.0.js"></script>

<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
<script src="${ctx}/resources/semanticui/semantic.js" type="text/javascript"></script>
<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'hideOptionMenu',
        'closeWindow']  
});

    var handler = { 
        activate: function() { 
            $(this).addClass('active').siblings().removeClass('active'); 

            if($(this).attr('id') == 'closeit') {
                wx.closeWindow();
            }

            if($(this).attr('id') == 'next') {

                var hrid           = $("#employerId").val();
                var companycontact = $("#companycontact").val();
                var companyphone   = $("#companyphone").val();
                var companyname    = $("#companyname").val();
                var companyaddress = $("#companyaddress").val();
              //  var orgcode        = $("#orgcode").val();
              //  var bizcode        = $("#bizcode").val();
                var companyemail   = $("#companyemail").val();
                var domainid       = $("#domainid").val();
    var tags = $('#tags').val();
                var scope = $('#scope').val();
                var property = $('#property').val();
                var position = $('#position').val();


                if(!companyname) {
                    alert("您必须输入公司名称");
                    return false;
                }
                if(!property) {
                    alert("您必须选择公司性质");
                    return false;
                }
                if(!scope) {
                    alert("您必须选择公司规模");
                    return false;
                }
                if(!domainid) {
                    alert("您必须选择细分领域");
                    return false;
                }

                if(!companyaddress || companyaddress=="" || companyaddress.length > 50) {
                  alert("您必须输入公司地址");
                  return false;
              }
                if(!companycontact) {
                    alert("您必须输入联系人姓名");
                    return false;
                }
                if(!companyphone) {
                    alert("您必须输入联系人电话");
                    return false;
                }
                if(!position) {
                    alert("您必须输入联系人职位");
                    return false;
                }
               /* if(!companyphone || companyphone=="" || companyphone.length <5 || companyphone.length>18) {
                    alert("您必须输入公司电话");
                    return false;
                }
                var regEx1 = /^([0-9]|[\-])+$/g;
                if (!companyphone.match(regEx1)) {
                    alert("您必须输入合格的公司电话");
                    return false;
                }
               
               if(!orgcode || orgcode=="" || orgcode.length > 20) {
                    alert("您必须输入合格的公司组织代码");
                    return false;
                }
                if(!bizcode || bizcode=="" || bizcode.length >20) {
                    alert("您必须输入营业执照编码");
                    return false;
                }
                if(!companyemail || companyemail=="") {
                    alert("您必须输入公司邮箱");
                    return false;
                }
                var re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm;
                if(!re.test(companyemail)) {
                    alert("您必须输入合格的电子邮箱");
                    return false;
                }*/

                $(this).addClass('disabled');
                var that = this;

                //var postUrl = '${ctx}/wechat/company/create2.do';
                var postUrl = '${ctx}/wechat/company/create1_2.do';
                var param = {};
                param['companycontact']  = companycontact;
                param['companyname'] = companyname;
               param['companyphone'] = companyphone;
                param['companyaddress'] = companyaddress;
               // param['companyemail'] = companyemail;
                param['domainid'] = domainid;
                param['hrid']    = hrid;
                param['englishName']= $("#englishname").val();
               // param['orgcode'] = orgcode;
                //param['bizcode'] = bizcode;
                param['tags']= tags;
                param['property']= property;
                param['scope']= scope;
                param['position']= position;

                $.ajax({ 
                    url: postUrl, 
                    type: "POST", 
                    data: param,
                    success: function(response){   
                        if(response.errorcode=="0"){
                            // var companyId = response.data;
                            <%--location.href = '${ctx}/wechat/employer/confirm.page?hrId='+hrid;--%>
                            alert("操作成功");
                            wx.closeWindow()
                        }else{
                            alert(response.msg); 
                            wx.closeWindow();
                        }
                    }, 
                    error: function(){ 
                        alert("服务出错，请稍后尝试"); 
                        $(that).removeClass('disabled');
                    } 
                });
               
            }
        } 
    };

    $(document).ready(function() { 
       
            $('.button').on('click', handler.activate);
            $('.dropdown').dropdown({
                fullTextSearch:true,
            });
            wx.ready(function() { 
            wx.hideOptionMenu();
        });
    });

</script>
</body>
</html>